<template>
    <div>
        <!--    <Header></Header>-->
        <div class="wrapper">
            <div class="ex-overview">
                <HomeSection :data="mainInfo"></HomeSection>
                <div class="ex-new-overview">
                    <div class="eno-left">
                        <div class="ex-new-overview-title">
                            <p>News</p>
                        </div>
                        <div class="ex-new-overview-title2">
                            <p>Overview</p>
                        </div>
                        <div class="ex-new-overview-learn-more" @click="search">
                            <span>Learn more</span>
                        </div>
                    </div>
                    <div class="eno-right">
                        <div class="ex-new-overview-carousel">
                            <div class="swiper mySwiper1">
                                <div class="swiper-wrapper">
                                    <div class="swiper-slide" v-for="(item, index) in overviewList"
                                         @click="turnTo(item.type,item.id)">
                                        <div class="img-box">
                                            <img :src=item.thumbnailUrl>
                                        </div>
                                        <div class="img-title">
                                            {{ item.title }}
                                        </div>
                                        <div class="img-content">
                                            <span>{{ item.contentType }}</span>
                                            <span>{{ dateFilter(item.publishTime, "MM/dd/yyyy") }}</span>
                                        </div>
                                    </div>
                                </div>
                                <div class="swiper-pagination"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <HomeMediaService></HomeMediaService>

            <HomeMediaInfos :data="mediaInfos"></HomeMediaInfos>

<!--            <HomeModels :data="models"></HomeModels>-->

            <HomePictures :data="pictures"></HomePictures>

            <HomeTheMedia :data="videos"></HomeTheMedia>

            <HomeMilestone :data="milestone"></HomeMilestone>

        </div>
        <!--    <Footer></Footer>-->
    </div>
</template>

<script setup lang="ts">
    import {ref, reactive} from 'vue'
    import Swiper from 'swiper';

    useHead({
        title: 'EXEED Newsroom',//网站标题
        meta: [{name: 'description', content: 'Exeed Media Centor '}],
        link: [//网站link，可以在这里引入css和icon等
            {rel: 'shortcut icon', href: '/images/favicon.ico'},
            {rel: 'apple-touch-icon', href: '/images/favicon.ico'}
        ]
    })
    const config = useRuntimeConfig();
    const apiURL = config.public.apiURL;
    // const hostURL = config.public.hostURL;
    const router = useRouter();

    const route = useRoute()

    // 当访问/posts/1时，route.params.id将为1

    const token = route.query.token;

    // const {data: content} = token ? await useFetch(`/api/page/getSketchHomePage?token=${token}`) : await useFetch(`/api/page/getHomePage`);
    const {data: content} = token ? await useFetch(`/api/page/getSketchHomePage?token=${token}`) : await useFetch(`/api/page/getHomePage`);

    // console.log(content.value)

    const overviewList = ref([]);

    overviewList.value = content.value.data.pageContent.news_overview;
    const mainInfo = content.value.data.pageContent.main_info;
    const mediaInfos = content.value.data.pageContent.media_infos;
    const models = content.value.data.pageContent.models;
    const milestone = content.value.data.pageContent.milestone;
    const pictures = content.value.data.pageContent.pictures;
    const videos = content.value.data.pageContent.videos;


    const turnTo = (type, id) => {
        router.push({
            path: `/${type}/${id}`
        })
    }
    let count = 0;
    onMounted(() => {

        let swiper1 = new Swiper(".mySwiper1", {
            slidesPerView: "auto",
            centeredSlides: false,
            // spaceBetween: 32,
            // grabCursor: true,
            loop: true,
            // autoplay: {
            //     delay: 1000,
            //     disableOnInteraction: false
            // },
            pagination: {
                el: ".swiper-pagination",
                clickable: true,
            },
        });
        setInterval(() => {
            swiper1.slideNext();
        }, 3000);
    })

    const search = () => {
        router.push({
            path: `/search`, query: {type: 0, key: ''}
        })
    }
</script>
<style scoped lang="scss">
    .ex-overview {
        // height: 1080px;
        // background-image: url('/images/ex-overview-bg.png');
        background-size: cover;
        /* 背景图片覆盖整个元素 */
        background-position: center;
        /* 背景图片居中显示 */
        background-color: #fff;
        position: relative;
        // min-width: 1200px;

        .ex-overview-header {
            position: relative;
            width: 1920px;
            // min-width: 1200px;
            height: 96px;
            background: #372E2C;
            border-radius: 0px 0px 0px 0px;
            opacity: 0.85;
            position: fixed;
            z-index: 999;
            display: inline-flex;
            align-items: center;

            .ex-header-brand {
                width: 70px;
                // height: 20px;
                font-weight: 400;
                font-size: 18px;
                color: #C78E66;
                line-height: 15px;
                text-align: left;
                font-style: normal;
                text-transform: none;
                margin-left: 160px;
            }

            .ex-header-brand-title {
                width: 104px;
                height: 21px;
                font-weight: 400;
                font-size: 18px;
                color: #FFFFFF;
                line-height: 15px;
                text-align: left;
                font-style: normal;
                text-transform: none;
            }

            .ex-header-brand-logo {
                position: absolute;
                left: 866px;
                top: 24px;

                // transform: translate(-50%, -50%);
                img {
                    width: 190px;
                }
            }


            .ex-header-brand-search {
                position: absolute;
                right: 160px;
                top: 30px;
                // transform: translateY(-50%);

                .ex-header-brand-search-wrapper {
                    padding-bottom: 8px;
                    width: 400px;
                    border-bottom: 1px solid #FFFFFF;
                    display: flex;
                    align-items: center;
                    /* 垂直居中所有子元素 */
                    justify-content: start;

                    /* 子元素向行的起始位置对齐 */
                    img {
                        cursor: pointer;
                        margin-right: 7px;
                        width: 24px;
                    }

                    input {
                        border: none;
                        /* 移除边框 */
                        outline: none;
                        /* 在选中时移除轮廓线 */
                        background-color: transparent;
                        /* 设置背景色为透明 */
                        caret-color: #ffffff;
                        /* 字体大小 */
                        font-size: 14px;
                        color: #FFFFFF;
                    }

                    input::-webkit-input-placeholder {
                        font: 14px
                    }
                }
            }

        }

        .ex-new-overview {
            position: relative;
            width: 1920px;
            display: inline-flex;
            // justify-content: space-between;
            padding-top: 150px;
            // padding-left: 160px;

            .eno-left {
                margin-left: 160px;
                width: 550px;

                .ex-new-overview-title {
                    width: 345px;
                    height: 120px;
                    font-family: PingFang SC, Hiragino Sans GB, Microsoft YaHei, WenQuanYi Micro Hei, Helvetica Neue, Arial, sans-serif;
                    font-weight: 700;
                    font-size: 150px;
                    color: #000;
                    line-height: 88px;
                    text-align: left;
                    font-style: normal;
                    text-transform: none;
                    // margin-bottom: 290px;


                }

                .ex-new-overview-title2 {
                    width: 345px;
                    height: 168px;
                    font-family: PingFang SC, Hiragino Sans GB, Microsoft YaHei, WenQuanYi Micro Hei, Helvetica Neue, Arial, sans-serif;
                    font-weight: 300;
                    font-size: 95px;
                    color: #000;
                    // line-height: 88px;
                    text-align: left;
                    font-style: normal;
                    text-transform: none;
                    margin-bottom: 200px;

                }

                // .ex-new-overview-learn-more {
                //     width: 240px;
                //     height: 60px;
                //     display: flex;
                //     justify-content: center;
                //     align-items: center;
                //     background-color: rgba(255, 255, 255, 0.08);
                //     border-radius: 0px 0px 0px 0px;
                //     cursor: pointer;
                //     border-bottom: 4px solid rgba(199, 142, 102, 1);
                //     transition: width 0.5s ease-in-out;

                //     span {
                //         width: 87px;
                //         height: 21px;
                //         font-weight: 400;
                //         font-size: 16px;
                //         color: #FFFFFF;
                //         line-height: 22px;
                //         text-align: left;
                //         font-style: normal;
                //         text-transform: none;
                //     }
                // }

                // .ex-new-overview-learn-more:hover {
                //     background-color: rgba(0, 0, 0, 0.15);
                //     border-bottom: 4px solid rgba(199, 142, 102, 0.5);
                //     /* 鼠标悬浮时显示蓝色下边框 */
                //     transition: background-color 0.3s ease-in-out, border-bottom-color 0.3s ease-in-out;
                //     /* 渐变过渡效果 */
                // }

                .ex-new-overview-learn-more {
                    user-select: none;
                    margin-top: 65px;
                    width: 296px;
                    height: 60px;
                    line-height: 60px;
                    text-align: center;
                    background: rgb(199, 142, 102, 0.08);
                    border-bottom: 4px solid #C78E66;
                    color: #000000;
                    cursor: pointer;
                    transition: background-color .3s;
                    font-size: 16px;
                }

                .ex-new-overview-learn-more:hover {
                    background-color: rgb(199, 142, 102, 0.38);
                }


            }

            .eno-right {
                // width: 1239px;

                .ex-new-overview-carousel {
                    // height: 520px;
                    width: 1050px;
                    height: 600px;

                    .swiper-slide {
                        width: 424px !important;
                        margin-right: 32px;
                        cursor: pointer;

                        .img-box {
                            width: 424px;
                            height: 520px;
                            background: rgba(255, 255, 255, 0.25);
                            border-radius: 0px 0px 0px 0px;
                            overflow: hidden;

                            img {
                                width: 424px;
                                height: 520px;
                                transition: all 0.6s;
                                object-fit: cover;
                            }

                            img:hover {
                                transform: scale(1.05);
                            }
                        }

                        .img-title {
                            width: 424px;
                            color: #000;
                            font-size: 16px;
                            margin-top: 24px;
                            // margin-bottom: 16px;
                        }

                        .img-content {
                            width: 424px;
                            margin-top: 10px;

                            span {
                                font-size: 12px;

                                &:first-child {
                                    margin-right: 12px;
                                    color: #C78E66;
                                }

                                &:last-child {
                                    color: #000;
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    /*
    .em-more-btn {
        margin-top: 65px;
        width: 296px;
        height: 60px;
        line-height: 60px;
        text-align: center;
        background: rgb(199, 142, 102, 0.08);
        border-bottom: 4px solid #C78E66;
        color: #000000;
    }
    */

    .ex-footer {
        position: relative;
        width: 1920px;
        height: 480px;
        background-color: #372E2C;

        .logo {
            margin-top: 60px;
            margin-left: 130px;
            width: 190px;

        }

        .ef-bottom {
            height: 120px;
            width: 1920px;
            position: absolute;
            left: 0;
            bottom: 0;
            color: rgba(255, 255, 255, 0.45);
            font-size: 14px;
            display: inline-flex;
            align-items: center;
            justify-content: space-between;
            border-top: 1px solid rgba(255, 255, 255, 0.15);
            padding: 40px 160px 60px 160px;

            span {
                margin-right: 32px;
            }

            img {
                width: 32px;
                height: 32px;
                margin-right: 40px;
            }

            img:hover {
                background-color: #C78E66;
                border-radius: 50%;
            }
        }
    }

    .inline {
        display: inline-block;
    }

    .link {
        cursor: pointer;
    }

    .link:hover {
    }
</style>
